package com.wsl.sale.logback;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.LayoutBase;

/**
 * @Author:wangshuliang
 * @Description:  自定义layout输出
 * @Date:Created in 17:49 2019/5/2
 * @Modified by:
 */
public class MySampleLayout extends LayoutBase<ILoggingEvent> {
    @Override
    public String doLayout(ILoggingEvent event) {
        StringBuffer sbuf =  new StringBuffer(128);
        sbuf.append(event.getTimeStamp()-event.getLoggerContextVO().getBirthTime());
        sbuf.append("  ");
        sbuf.append(event.getLevel());
        sbuf.append("[");
        sbuf.append(event.getThreadName());
        sbuf.append("]  ");
        sbuf.append(event.getLoggerName());
        sbuf.append(" - ");
        sbuf.append("goodboy   --  ");
        sbuf.append(event.getFormattedMessage());
        sbuf.append(CoreConstants.LINE_SEPARATOR);
        return sbuf.toString();
    }
}
